home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: [] overload..(newbie in distress)
- Date: 22 Jan 1996 19:34:22 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan22143422@g7240065.bridge.bst.bls.com>
- References: <DLGppJ.31C@undergrad.math.uwaterloo.ca>
- <Robert.Lendvai-2101960118330001@129.170.80.94>
- <4dtuam$hf4@news.xmission.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: tknarr@xmission.com's message of 21 Jan 1996 17:49:10 GMT
-
- In article <4dtuam$hf4@news.xmission.com> tknarr@xmission.com ( Todd Knarr ) writes:
-
- : tthiraku@landen.math.uwaterloo.ca (Thanou Thirakul) wrote:
- :> A[5] = val; // store val into the fifth node of a linklist.
- :> val = A[5] ; // returns the value of the fifth node of a linklist.
-
- T& operator [] (int index);
- T operator [] (int index) const;
-
- : It involves the return value of the operator[]() function. If it
- : returns a reference, you can use it on the left side of the assignment.
- : If it returns a non-reference, you can't.
-
- A reference can also be used on the right of an assignment also.
-
- Does anyone have any good reasons or references as why you should define the
- second of the two operator []'s if you provide the first ?
- And if it is necessary what is the argument against
-
- const T& operator [] (int index) const;
-
- instead ?
-
- Regards
-
- -A.
- --
- | A.Champion |
-